﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace HtmlEditProgram
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            newHTMLTab();
            listStatuslabels();
            //toolbox opening
            toolbox.Html html = new toolbox.Html(this);
            html.Show();
        }
        //Toolbox Functions
        public void addDefaultsHtml()
        {
            TextBox editbox = (TextBox)tabControl1.TabPages[tabControl1.SelectedIndex].Controls[0];
            editbox.Text += "<html>\r\n" +
            "     <head>\r\n    </head>\r\n" +
            "    <body>\r\n    </body>\r\n</html>";
        }

        //Tabpage section
        int TabpageCount = -1;

        public void newHTMLTab()
        {
            tabControl1.TabPages.Add("New File");
            TabpageCount++;
            TextBox editbox = new TextBox();
            editbox.Dock = DockStyle.Fill;
            editbox.Multiline = true;
            editbox.Font = new System.Drawing.Font(new FontFamily("arial"), 10, FontStyle.Regular);
            editbox.Text = "<html>\r\n" +
            "     <head>\r\n    </head>\r\n" +
            "    <body>\r\n    </body>\r\n</html>";
            tabControl1.TabPages[TabpageCount].Controls.Add(editbox);
        }

        //Statusstrip

        List<ToolStripStatusLabel> statusLabelList;
        private void listStatuslabels()
        {
            statusLabelList = new List<ToolStripStatusLabel>();
            statusLabelList.Add(statusLabel1);

        }

        public void showOnStatusInString(string text,int index, int duration)
        {
            statusLabelList[index].Text = text;
            if (duration != 0)
            {
                Timer statusTimer = new Timer();
                statusTimer.Interval = duration;
                statusTimer.Start();
                statusTimer.Tick += statusTimer_Tick;
            }
            else
            {

            }
        }

        void statusTimer_Tick(object sender, EventArgs e)
        {
            showOnStatusInString("",0,0);
        }

        //Local events

        private void newToolStripButton_Click(object sender, EventArgs e)
        {
            newHTMLTab();
        }
    }
}
